﻿using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using PomeloEfCoreSample.Data.Core;
using System;
using System.Collections.Generic;
using System.Text;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
using PomeloEfCoreSample.Data.Mapping;

namespace PomeloEfCoreSample.Data
{
    public class ApplicationContext
        : DbContext
    {
        public ApplicationContext(DbContextOptionsBuilder options) 
            : base()
        {
            options.UseMySql("server=.;database=pomelo_mysql;uid=root;pwd=p@ssw0rd");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.ApplyConfiguration(new UserMap());
            modelBuilder.ApplyConfiguration(new RoleMap());
            base.OnModelCreating(modelBuilder);
        }
        public virtual DbSet<User> User { get; set; }
        public virtual DbSet<Role> Role { get; set; }
    }
}
